package EA;

public class Individual 
{
  public Genome genome;
  public Framework framework;

  public Individual(Framework frame)
    {
      super();
      framework = frame;
      genome = new Genome(frame);
    }

  /** Create an individual with gen as its genome. */ 
  public Individual(Framework frame, Genome gen)
    {
      super();
      framework = frame;
      genome = gen;
    }

  /** Perform crossover between this individual and otherIndividual.
      @deprecated Don't use this method it might be removed!
   */
  public Individual crossover(Individual otherIndividual)
    {
      return new Individual(framework, genome.crossover(this.genome, otherIndividual.genome));
    }

  /** Perform crossover between individual1 and individual2.
   */
  public static Individual crossover(Individual individual1, Individual individual2)
    {
      return new Individual(individual1.framework, individual1.genome.crossover(individual1.genome, individual2.genome));
    }

  /** Mutate this individual. This method calls genome.mutate(p_m) Override this if you have a 
      more sofisticated individual. 
      @param p_m Probability for mutation.
  */
  public void mutate(double p_m)
    {
      genome.mutate(p_m);
    }

  /** You must override this to provide the fitness. */
  public double getFitness()
    {
      return 0;
    }
}
